<?php
/**
 * UBaseController : U, means user, for login-needed pages
 * 充当拦截器, 过滤未登录用户至登录页面 & 无权限用户至首页
 *
 * Created by PhpStorm.
 * User: silov
 * Date: 16/1/5
 * Time: 10:10
 */
namespace Common\Controller;

use Think\Controller;

class UBaseController extends Controller
{
    /**
     * @var HTTP参数集合体
     */
    public $params;

    /**
     * 验证签名
     */
    protected function _checkSign()
    {
        $sign = $this->params['sign'];
        unset($this->params['sign']);

        ksort($this->params);
        $rightSign = md5( http_build_query($this->params) . md5("PaRaMsKeY!@#$&^%") );

        if ($sign !== $rightSign) {
            $this->ajaxReturn(['status'=>'10001', 'msg'=>'无权限']);
        }
    }
}